﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;

namespace WebBanHang.GUI
{
    public partial class ProductDetail : System.Web.UI.Page
    {
        public string Datestring;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoadSP();
            }
        }
        void LoadSP()
        {
            if (Request.QueryString["ID"] != null)
            {
                string id = Request.QueryString["ID"].ToString();
                string sql;
               
                sql =string.Format("Select * from Deal where MaDeal = '{0}'", id);
                
                SqlCommand cmd = new SqlCommand(sql);
                SqlParameter[] pr = { new SqlParameter("@NgayHienTai", DateTime.Now.Date) };
                DataTable DATA = new DataTable();
                DATA = DataProvider.LoadTable(cmd, pr);
                DataList1.DataSource = DATA;
                DataList1.DataBind();
                string format = "ddd MMM d yyyy HH:mm:ss";
                DateTime _TempDate = Convert.ToDateTime(DATA.Rows[0]["NgayKetThuc"]);
                Datestring = _TempDate.ToString(format);                
            }
            else
            {
                //string url = ViewState["RefUrl"] == null ? "~/GUI/Home.aspx" : ViewState["RefUrl"].ToString();
                Response.Redirect("~/GUI/Home.aspx");
            }
        }

        protected void btMuaHang_Click(object sender, EventArgs e)
        {
            Response.Redirect(string.Format("DatHang.aspx?MaDeal={0}",Request.QueryString["ID"].ToString()));
        }
    }
}